using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bundle:Mob {

	[SerializeField] int swarmerCount;
	[SerializeField] GameObject swarmerObject;

	protected override void StateAttack() {
		base.StateAttack();
		if(stateTime>0.5f) {
			swarmerCount-=3;
			int count = Random.Range(3,6);
			for(int _ = 0;_<count;_++) {
				if(swarmerCount<=0) break;
				swarmerCount--;
				GameObject newObject = Instantiate(swarmerObject,transform.position,Quaternion.identity,transform.parent);
				newObject.GetComponent<Mob>().faction=faction;
			}
			GoIdle();
		}
	}

	protected override void FixedUpdate() {
		if(swarmerCount<=0) HP=-1;
		base.FixedUpdate();
	}

	protected override void Die() {
		base.Die();
		for(int i = 0;i<swarmerCount/2;i++) {
			GameObject newObject = Instantiate(swarmerObject,transform.position,Quaternion.identity,transform.parent);
			newObject.GetComponent<Mob>().faction=faction;
		}
	}

}
